Hello ladies and gentleman, especially the Highcharts community.
I've been trying to update my pie chart in order to update it on mouseover but it gives me the following error:
Uncaught TypeError: can't access property "linkedParent", d is null
I am new into Highcharts but was curious why would it give me the following error. I have to be honest, it got me stumped, the expected behavior would be updating chart upon mouseover. Any help would be appreciated :)
export const DonutChart = ({
total,
title,
}) => {
const [percentage, setPercentage] = useState(100);
const [rawData, setRawData] = useState([
{y: percentage, color: 'grey'},
]);
const options = {
chart: {
renderTo: 'container',
type: 'pie',
width: 80,
height: 80,
spacing: [0, 0, 0, 0],
},
title: {
text: '',
},
subtitle: {
text: '',
},
credits: {
enabled: false,
},
legend: {
enabled: false,
},
plotOptions: {
pie: {
size: 80,
innerSize: 45,
shadow: false,
dataLabels: [{
enabled: false,
}],
states: {
hover: {
lineWidth: 0,
halo: {
size: 0,
},
},
},
events: {
mouseOver: () => {
let sum = 0;
setRawData([
{y: (3000 / total) * 100, color: '#EE76B0'},
{y: (3000 / total) * 100, color: '#18D39B'},
{y: ((total - 6000) / total) * 100, color: 'grey'},
]);
setPercentage((6000 / total) * 100);
},
mouseOut: () => {
setPercentage(100);
},
},
},
},
tooltip: {
enabled: false,
},
series: [{
data: [...rawData],
}],
};
return (
<div className={styles.body}>
<div className={styles.body__chart}>
<HighchartsReact
highcharts={Highcharts}
options={options}
constructorType="chart"
/>
<p className={styles.body__chart__percentage}>{`${percentage}%`}</p>
</div>
<p className={styles.body__chart__title}>{title}</p>
</div>
);
};